package com.iris.live.services.data.models;

import javax.persistence.*;

/**
 * Created by DF on 9/19/2016.
 */
@Entity
@Table(name = "roleItem", schema = "", catalog = "")
@IdClass(RoleItemModelPK.class)
public class RoleItemModel {
    private String permit;
    private int roleId;
    private int itemId;

    @Id
    @Column(name = "permit")
    public String getPermit() {
        return permit;
    }

    public void setPermit(String permit) {
        this.permit = permit;
    }

    @Id
    @Column(name = "roleId")
    public int getRoleId() {
        return roleId;
    }

    public void setRoleId(int roleId) {
        this.roleId = roleId;
    }

    @Id
    @Column(name = "itemId")
    public int getItemId() {
        return itemId;
    }

    public void setItemId(int itemId) {
        this.itemId = itemId;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RoleItemModel that = (RoleItemModel) o;

        if (roleId != that.roleId) return false;
        if (itemId != that.itemId) return false;
        if (permit != null ? !permit.equals(that.permit) : that.permit != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = permit != null ? permit.hashCode() : 0;
        result = 31 * result + roleId;
        result = 31 * result + itemId;
        return result;
    }
}
